/**
 * Created by chengming on 18/5/27.
 * version 1.0
 */
const BaseJsonAdapter = require('../base/BaseJsonAdapter');
const iconv = require("iconv-lite");
const request = require('request-promise');

/**
 * 北京互金网
 * @type {module.Bjp2p}
 */
module.exports = class MarketRealist extends BaseJsonAdapter{

    async reqJson(){
        let echo = await request({
          url: 'https://api.marketrealist.com/api/category-by-slug/earnings-reports'
        });
        let id = JSON.parse(echo).id
        let html = await request({
          url: 'https://api.marketrealist.com/api/serie-category/' + id + '?limit=6&skip=0'
        });
        let contents = [];
        if (html) {
          html = JSON.parse(html)
          console.log(html)
          for(let row of html) {
            contents.push({
              title: row['title'],
              href: row['posts'][0]['link'].replace('http://editors.aws.marketrealist.com','https://marketrealist.com')
            });
          }
        }

        return {data:contents}
	  }
}
